//
// Created by wze-zero on 2024/10/25.
//
#include <iostream>

using namespace std;

int arr[1001][1001] = {0};

int main() {
    int n, i = 1, j = 1, pos = 1;
    cin >> n;
    arr[i][j] = 1;
    for (int k = 2; k <= n * n; ++k) {
        if (i == 1 && j < n && pos == 1) {
            arr[i][++j] = k;
            pos = -1;
        } else if (j == 1 && i < n && pos == -1) {
            arr[++i][j] = k;
            pos = 1;
        } else if (j == n && pos == 1) {
            arr[++i][j] = k;
            pos = -1;
        } else if (i == n && pos == -1) {
            arr[i][++j] = k;
            pos = 1;
        } else if (pos == 1) {
            arr[--i][++j] = k;
        } else if (pos == -1) {
            arr[++i][--j] = k;
        }
    }
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <= n; ++j) {
            cout << arr[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}